package com.unicorn;

import com.unicorn.base.PlatformListenner;
import com.unicorn.base.VinaceConfig;
import com.unicorn.modual.fts.controller.FtsContoller;
import com.unicorn.util.common.BaseComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import java.io.File;

@SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class NetVinaceApplication  implements EnvironmentAware {

	private static Logger logger= LoggerFactory.getLogger(NetVinaceApplication.class);

	public static void main(String[] args) {

		SpringApplication netVinaceApp=new SpringApplication(NetVinaceApplication.class);
		netVinaceApp.addListeners(new PlatformListenner());
		netVinaceApp.run(args);

		//SpringApplication.run(NetVinaceApplication.class,args).addApplicationListener(new PlatformListenner());



	}


	@Override
	public void setEnvironment(Environment env) {
		logger.info(env.getProperty("JAVA_HOME"));

		String systemRoot = env.getProperty("platform.online.file.system.root");
		String usersRoot = env.getProperty("platform.user.doc.root");
		VinaceConfig.ONLINE_FILE_SYSTEM_ROOT=systemRoot;
		VinaceConfig.PLATFORM_USER_DOC_ROOT=usersRoot;

		//logger.info(url);
	}
}
